package com.wc.alorithm_blue_bridge._模拟.Q7937;

/**
 * @Author congege
 * @Description 最多约数
 * https://www.lanqiao.cn/problems/7937/learning/?problem_list_id=25&page=1
 * @Date Created in 2023/12/19-23:21
 */
public class Main {
    public static void main(String[] args) {
        String s = "393353 901440 123481 850930 423154 240461\n" +
                "373746 232926 396677 486579 744860 468782\n" +
                "941389 777714 992588 343292 385198 876426\n" +
                "483857 241899 544851 647930 772403 109929\n" +
                "882745 372491 877710 340000 659788 658675\n" +
                "296521 491295 609764 718967 842000 670302";
        String[] ss = s.split("\\n");
        String ans = "";
        int max = 0;
        for (int i = 0; i < ss.length; i++) {
            String[] nums = ss[i].split("\\s+");
            for (int j = 0; j < nums.length; j++) {
                int m = many(Integer.parseInt(nums[j]));
                if (max < m) {
                    max = m;
                    ans = nums[j];
                }
            }
        }
        System.out.println(ans);
    }

    public static int many(int num) {
        int sq = (int) Math.sqrt(num);
        int ans = 0;
        for (int i = 1; i <= sq; i++) {
            if (num % i == 0) {
                ans += 2;
            }
        }
        if (sq * sq == num) {
            ans--;
        }
        return ans;
    }
}
